package Day09;

import java.util.Scanner;

public class Login {
   private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        System.out.println("请输入用户名");
        String username = sc.next();
        System.out.println("请输入密码");
        String password = sc.next();
        try{
            login(username,password);
        }catch(UsernameNotFoundException e){
            e.printStackTrace();
        }catch(BadException e){
            e.printStackTrace();
        }


    }

    public static void login(String username, String password)throws UsernameNotFoundException,BadException{
        if("admin".equals(username)){
            if("123456".equals(password)){
                System.out.println("登录成功");
            }else{
                throw new BadException("用户名或密码错误");
            }

        }else{
            throw new UsernameNotFoundException("用户名不存在");
        }
    }
}
